package cn.zebra.dev.product.module.comment.service.impl;

import cn.zebra.dev.ibatis.plus.service.impl.ServiceImpl;
import cn.zebra.dev.ibatis.plus.utils.PageUtils;
import cn.zebra.dev.ibatis.plus.utils.Query;
import cn.zebra.dev.product.module.comment.dao.ProductCommentDao;
import cn.zebra.dev.product.module.comment.entity.ProductCommentEntity;
import cn.zebra.dev.product.module.comment.service.ProductCommentService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 商品评论表
 *
 * @author runnable
 */
@Service
public class ProductCommentServiceImpl extends ServiceImpl<ProductCommentDao, ProductCommentEntity> implements ProductCommentService {

    @Override
    public PageUtils<ProductCommentEntity> findPage(Map<String, Object> params) {
        QueryWrapper<ProductCommentEntity> wrapper = new QueryWrapper<>();
        wrapper.apply("delete_flag = FALSE");
        wrapper.apply("product_id = {0}",params.get("productId"));
        IPage<ProductCommentEntity> page = this.page(
                new Query<ProductCommentEntity>(params).getPage(),
                wrapper
        );
        return new PageUtils<>(page);
    }
}
